package com.lc.user.express.ordering;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

import com.lc.user.express.BaseSecondActivity;
import com.lc.user.express.R;
import com.lc.user.express.adapter.AddrAdapter;
import com.lc.user.express.app.AppContext;
import com.lc.user.express.httpserver.GetAddrInfo;
import com.lc.user.express.model.AddrModel;
import com.zcx.helper.http.AsyCallBack;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/3/7.查看路线详情
 */
public class UsedRouteDetailsActivity extends BaseSecondActivity {
    private ListView lv;
    private List<AddrModel> list = new ArrayList<>();
    private AddrAdapter adapter;
    private TextView tv_route_name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_route_details);
        setTitle("查看路线详情");
        initView();
        getAddrData();
    }
    
    private void initView(){
        tv_route_name = (TextView)findViewById(R.id.tv_route_name);
        lv = (ListView) findViewById(R.id.lv);
        adapter = new AddrAdapter(cnt, list,false);
        lv.setAdapter(adapter);

        tv_route_name.setText(getIntent().getStringExtra("title"));

    }
    private void getAddrData(){
        new GetAddrInfo(AppContext.myPreferences.getUid(),getIntent().getStringExtra("routeId"),new AsyCallBack<GetAddrInfo.Info>() {
            @Override
            public void onSuccess(String toast, int type, GetAddrInfo.Info info) throws Exception {
                list.addAll(info.dataList);
                adapter.updateListView(list);
            }
        }).execute(cnt);
    }
}
